/**
 * Copyright 2013 DJSearch Co.,Ltd. All rights reserved.
 * DTM PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.police.controller;


import com.police.router.IRouter;
import com.police.router.DefaultRouter;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * @author dingzhongchang
 * @version 1.0.0
 */
public class JSONReq extends JSONObject implements IRequest {
    private static IRouter DefaultRouter = new DefaultRouter();
    private String url = "";

    public JSONReq(String method) {
        this.url = DefaultRouter.getMethodPath(method);
    }

    public JSONReq(String method, String json) throws JSONException {
        super(json);
        this.url = DefaultRouter.getMethodPath(method);
    }

    public JSONReq(String method, Map<String, String> map) {
        super(map);
        this.url = DefaultRouter.getMethodPath(method);
    }

    public JSONReq(String urlStr, String one, String two) {
        this.url = urlStr;
    }

    /**
     * @return
     * @see com.djsearch.controller.IRequest#url()
     */
    @Override
    public String url() {
        return "http://" + url;
    }

    @Override
    public void putParam(String key, Object value) {
        try {
            this.put(key, value);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    public String toParams() {
        return this.toString();
    }



}
